package com.itboye.mybatis.helper;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.github.pagehelper.Page;

import java.util.List;

/**
 * ByPageInfoHelper.java
 * Created on  2016/8/11 12:22
 * 版本       修改时间          作者      修改内容
 * V1.0.1    2016/8/11      hebidu    初始版本
 * <p>
 * Copyright (c) 2013 杭州博也网络科技有限公司 版权所有
 * HANGZHOU BOYE TECHNOLOGY CO.,LTD. All Rights Reserved.
 */
public class ByPageInfoHelper<T> {
//    page_num": 1,
//            "page_size": 10,
//            "total": 1,
//            "pages": 1,


    public ByPageInfoHelper(Page<T> page) {
        this.page = page;
    }

    @JsonIgnore
    private Page<T> page;

    private int pageNum;
    private int pageSize;
    private int total;
    private int pages;

    @JsonSerialize
    public List<T> getResult(){
        return page.getResult();
    }

    public int getPageSize() {
        if(page != null){
            pageSize = page.getPageSize();
        }
        return pageSize;
    }

    public int getTotal() {

        if(page != null){
            total = (int) page.getTotal();
        }

        return total;
    }



    public int getPages() {

        if(page != null){
            pages = page.getPages();
        }
        return pages;
    }


    public int getPageNum() {

        if(page != null){
            pageNum = page.getPageNum();
        }
        return pageNum;
    }
}
